package cn.edu.sdjzu.xg.eagle.service.impl;//package cn.edu.sdjzu.xg.bysj.service;

import cn.edu.sdjzu.xg.eagle.dao.UserAssRoleDao;
import cn.edu.sdjzu.xg.eagle.dao.mapper.UserAssRoleDaoImpl;
import cn.edu.sdjzu.xg.eagle.entity.User;
import cn.edu.sdjzu.xg.eagle.entity.authority.UserAssRole;
import cn.edu.sdjzu.xg.eagle.factory.DaoFactory;
import cn.edu.sdjzu.xg.eagle.service.UserAssRoleService;
import cn.edu.sdjzu.xg.eagle.util.JdbcHelper;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.Collection;

//
//
//import cn.edu.sdjzu.xg.bysj.dao.UserAssRoleDaoImpl;
//import cn.edu.sdjzu.xg.bysj.entity.User;
//import cn.edu.sdjzu.xg.bysj.entity.authority.UserAssRole;
//
//
//import java.sql.Connection;
//import java.sql.SQLException;
//import java.util.Collection;
//
public final class UserAssRoleServiceImpl implements UserAssRoleService {
    private UserAssRoleDao userAssRoleDao = DaoFactory.getDao(UserAssRoleDaoImpl.class, "UserAssRoleDaoImpl");
//    private static final UserAssRoleDaoImpl userAssRoleDaoImpl = UserAssRoleDaoImpl.getInstance();
//    private static final UserAssRoleServiceImpl
//    USER_ASS_ROLE_SERVICE = new UserAssRoleServiceImpl();
//
//    private UserAssRoleServiceImpl() {
//    }
//
//    public static UserAssRoleServiceImpl getInstance() {
//        return USER_ASS_ROLE_SERVICE;
//    }
//
    //获得某User对象关联的所有UserAssRole对象
    @Override
    public Collection<UserAssRole> findAll(User user) throws SQLException {
        //获取数据库连接
        Connection connection = JdbcHelper.getConn();
        Collection<UserAssRole> userAssRoles = userAssRoleDao.findAll(connection, user);
        JdbcHelper.close(connection);
        return userAssRoles;
    }
//
//    public Collection<UserAssRole> findAll() throws SQLException {
//        //获取数据库连接
//        Connection connection = JdbcHelper.getConn();
//        Collection<UserAssRole> userAssRoles = userAssRoleDaoImpl.findAll(connection);
//        //释放连接
//        JdbcHelper.close(connection);
//        return userAssRoles;
//    }
//
//    public UserAssRole find(Integer id) throws SQLException {
//        //获取数据库连接
//        Connection connection = JdbcHelper.getConn();
//        UserAssRole userAssRole = userAssRoleDaoImpl.find(connection, id);
//        //释放连接
//        JdbcHelper.close(connection);
//        return userAssRole;
//
//    }
//
//    public boolean update(UserAssRole userAssRole) throws SQLException {
//        //获取数据库连接
//        Connection connection = JdbcHelper.getConn();
//        boolean updated = userAssRoleDaoImpl.update(connection, userAssRole);
//        //释放连接
//        JdbcHelper.close(connection);
//        return updated;
//    }
//
//    public boolean add(UserAssRole userAssRole) throws SQLException {
//        //获取数据库连接
//        Connection connection = JdbcHelper.getConn();
//        boolean added = userAssRoleDaoImpl.add(connection, userAssRole);
//        //释放连接
//        JdbcHelper.close(connection);
//        return added;
//    }
//
//    public boolean delete(Integer id) throws SQLException {
//        boolean deleted = false;
//        Connection connection = JdbcHelper.getConn();
//        deleted = userAssRoleDaoImpl.delete(connection, id);
//        return deleted;
//    }
}

